<template>
  <div>
    <el-main>
      <h1 class="title">意见列表</h1>
      <div class="list">
        <div class="list-input">
          <el-input v-model="input" placeholder="请输入搜索关键字" />
        </div>
        <div class="cascader">
          <el-cascader
            :options="options"
            placeholder="请选择意见分类"
            v-model="OpinionClassification"
          />
        </div>

        <div class="block">
          <span class="demonstration"></span>
          <el-date-picker
            v-model="value2"
            type="daterange"
            start-placeholder="Start Date"
            end-placeholder="End Date"
            :default-value="[new Date(2023, 2, 1), new Date(2023, 3, 10)]"
          />
        </div>
        <div>
          <el-button type="primary" @click="search">搜索</el-button>
          <el-button type="danger" plain @click="clear">重置</el-button>
        </div>
      </div>

      <div>
        <el-row>
          <el-col>
            <el-card class="car">
              <div class="comment" v-for="(item, index) in list" :key="index">
                <div>
                  <div class="subject">{{ item.title }}</div>
                  <p>{{ item.time }}</p>
                  <div class="conent">
                    {{ item.content }}
                  </div>
                  <div class="look" @click="onlock">查看</div>
                </div>
                <div class="right">
                  <div>
                    <div class="name">
                      <div class="log">
                        <!-- <img src="" alt="" /> -->
                      </div>
                      <div>{{ item.author.username }}</div>
                    </div>

                    <div class="role">{{ item.author.label }}</div>
                    <div class="idea">
                      <div class="span">{{ item.type[0] }}</div>
                      <div class="span">{{ item.type[1] }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </div>
      <div class="foot">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="list.length"
          :page-size="5"
        />
      </div>
    </el-main>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted } from "vue";
import { getadviselist } from "../../../api/api";
import { useRouter } from "vue-router";
const router = useRouter();
const value2 = ref("");
const input = ref("");
const OpinionClassification = ref("");
let formData = reactive([{}]);
const list = ref([]);
const arr = ref();
const options = reactive([
  {
    value: "fuwuyijian",
    label: "服务意见",
    children: [
      {
        value: "baoxianyijian",
        label: "保险服务",
      },
      {
        value: "weixiuyijian",
        label: "维修服务",
      },
      {
        value: "huifangyijian",
        label: "回访服务",
      },
      {
        value: "disciplinesadas",
        label: "客服服务",
      },
    ],
  },
  {
    value: "good",
    label: "绩效意见",
    children: [
      {
        value: "disclinedffsdasds",
        label: "加班意见",
      },
      {
        value: "discipsadas",
        label: "薪资意见",
      },
    ],
  },
  {
    value: "good",
    label: "其他意见",
    children: [
      {
        value: "disclinedffsdasds",
        label: "生活意见",
      },
      {
        value: "discipsadas",
        label: "服务意见",
      },
      {
        value: "discipsadas",
        label: "前台意见",
      },
    ],
  },
]);

const search = async () => {
  //搜索
  console.log("value2._rawValue", value2._rawValue);
  const res = await getadviselist({
    date: value2._rawValue,
    keyword: input.value,
    type: OpinionClassification.value,
  });
  console.log(res, "res.value");
  if (res.code === 200) {
    res.result.forEach((item) => {
      if (item.author) {
        list.value.push(item);
      }
    });
    // console.log(formData, "formData");
    // console.log(list.value, "list");
  }
};
const clear = () => {
  //重置
  (value2.value = ""), (input.value = ""), (OpinionClassification.value = "");
};

const onlock = () => {};
onMounted(() => {
  search();
});
</script>

<style lang="scss" scoped>
.title {
  font-size: 2rem;
  color: #f49;
}

.list {
  display: flex;
  height: 2rem;
  .list-input {
    width: 15rem;
    margin-right: 3rem;
  }
  .cascader {
    margin-right: 3rem;
  }
  .block {
    margin-right: 3rem;
  }
}
.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}
.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
.comment {
  display: flex;
  justify-content: space-between;
  margin-left: 3rem;
  .conent {
    width: 40rem;
    height: 8rem;
    background-color: #fff;
    // line-height: 3rem;
    font-size: 1rem;
    padding: 2rem;
    margin-bottom: 1rem;
    border-radius: 2rem;
  }
}
.car {
  width: 75%;
  font-size: 1.2rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin: 20px 0;
  background-color: #f2f6fc;
}
.look {
  color: #1890ff;
}
.right {
  margin-right: 3rem;
  text-align: center;
}
.role {
  width: 4rem;
  height: 2rem;
  background-color: #310ce9;
  color: #fff;
  border-radius: 0.2rem;
  margin-bottom: 1rem;
}
.idea {
  width: 10.5rem;
  display: flex;
  justify-content: space-between;
  .span {
    background-color: #ff9900;
    color: #fff;
    border-radius: 0.2rem;
  }
}
.log {
  width: 3rem;
  height: 3rem;
  background-color: #000;
  border-radius: 3rem;
  margin-right: 1rem;
}
.name {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}
.subject {
  font-weight: 900;
  margin-bottom: 1rem;
}
.foot {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 1rem;
  margin-right: 3rem;
}
</style>